﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace DataBaseReverseGenerator.DataBaseModel
{
    [Serializable]
    public class DataBase
    {
        #region Ctor

        public DataBase()
        {
            this.tables = new List<Table>();
            this.relationShips = new List<RelationShip>();
        }

        public DataBase(string name) : this()
        {
            this.name = name;
        }

        #endregion

        #region Properties

        private string name;
        [XmlAttribute()]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
	
        private List<Table> tables;
        public List<Table> Tables
        {
            get { return tables; }
            set { tables = value; }
        }

        private List<RelationShip> relationShips;
        public List<RelationShip> RelationShips
        {
            get { return relationShips; }
            set { relationShips = value; }
        }

        #endregion

        #region Methods

        public void Serialize(string fileName)
        {
            using (StreamWriter writer = new StreamWriter(fileName))
            {
                XmlSerializer xmlSer = new XmlSerializer(typeof(DataBase));
                xmlSer.Serialize(writer, this);
            }
        }

        #endregion
    }
}
